import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsOptional, IsInt, Min } from 'class-validator';
import { Type } from 'class-transformer';

export class PaginationDto { //页码数据传输对象的公共定义
  @ApiPropertyOptional({ description: '页码', default: 1 })
  @IsOptional() // 字段可选
  @Type(() => Number) // 让 class-transformer 把 query 参数从字符串转换为数字
  @IsInt()
  @Min(1)
  page?: number = 1;  //设置默认值

  @ApiPropertyOptional({ description: '每页条数', default: 10 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  pageSize?: number = 10;
}